package com.quasar.hpatient.view.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.quasar.hpatient.MainAppliaction;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.custommodel.TemperatureTableItem;

import java.util.List;

/**
 * author : 许建宏
 * Date: 2017/10/26 0026
 * View:历史日常记录
 */

public class HistoryRecordAdapter extends BaseMultiItemQuickAdapter<TemperatureTableItem, BaseViewHolder> {

    public HistoryRecordAdapter(List<TemperatureTableItem> data) {
        super(data);
        addItemType(TemperatureTableItem.HEAD, R.layout.widget_temperature_medicine);
        addItemType(TemperatureTableItem.BODY, R.layout.widget_temperature_medicine);
    }

    @Override
    protected void convert(BaseViewHolder helper, TemperatureTableItem item) {

        switch (helper.getItemViewType()) {
            case TemperatureTableItem.BODY:
                helper.setText(R.id.tv_time, item.getDailyitemName());
//                    if(item.getReferenceValue().indexOf("~")!=-1){
//                        String[] values = item.getReferenceValue().split("~");
//                    }
                helper.setText(R.id.tv_val, item.getLogValue() + "");
                helper.setText(R.id.tv_company, item.getDailyitemDose());
                break;
        }
        helper.addOnClickListener(R.id.tv_time);
    }

    private int color(int value) {
        return MainAppliaction.getInstance().getResources().getColor(value);
    }
}
